from django.db import models
from apps.common.base.models import BaseModel

class Log(BaseModel):

    types = (
        ('create', "新增"),
        ('update', "修改"),
        ('delete', "删除"),
        ('user', "用户日志")
    )

    byUser=models.ForeignKey("user.UserModel", related_name='log_byUser', verbose_name='操作人', on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False)
    tableName = models.CharField("表名", max_length=100, null=True, blank=True, default='')
    recordId = models.CharField("记录Id", max_length=100, null=True, blank=True, default='')
    oldContent = models.TextField("修改前内容", max_length=10000, null=True, blank=True, default='')
    newContent = models.TextField("修改后内容", max_length=10000, null=True, blank=True, default='')
    types = models.CharField("类型", max_length=20, choices=types, default='')

    class Meta:
        verbose_name = '日志'
        verbose_name_plural = verbose_name